<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2024-02-27
  Time: 16:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .number{
            height: 30px;
            border: 1px solid blue;
        }
        .jian img{
            cursor: pointer;
            height: 16px;
        }
        .jian{
            z-index: 100;
            position: absolute;
            margin-left: 140px;
        }
    </style>
</head>
<body>
<div>
    <div style="position: relative;">
        <div class="jian" style="">
            <div><img class="arrow-up" src="img/exam/上箭头.png"></div>
            <div><img class="arrow-down" src="img/exam/下箭头.png"></div>
        </div>
        <input class="number" value="1">
    </div>
</div>
<div>
    <div style="position: relative;">
        <div class="jian">
            <div><img class="arrow-up" src="img/exam/上箭头.png"></div>
            <div><img class="arrow-down" src="img/exam/下箭头.png"></div>
        </div>
        <input class="number" value="1">
    </div>
</div>

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
    $(document).ready(function() {
        // 监听上箭头的点击事件
        $(".arrow-up").click(function() {
            // 寻找最近的输入框
            var input = $(this).closest("div.jian").next(".number");
            var value = parseInt(input.val());
            // 增加值，但不超过50
            if (value < 50) {
                input.val(value + 1);
            }
        });

        // 监听下箭头的点击事件
        $(".arrow-down").click(function() {
            // 寻找最近的输入框
            var input = $(this).closest("div.jian").next(".number");
            var value = parseInt(input.val());
            // 减少值，但不低于1
            if (value > 1) {
                input.val(value - 1);
            }
        });
    });

</script>

</body>
</html>
